<?php $user=Member::model()->find("username=:username",array("username"=>$_GET['username']));?>

<?php $this->beginContent('//layouts/user_master'); ?>
<div class="span3">
	<div class="well sidebar-nav">
		<?php $this->renderPartial("/part/member",array("member"=>$user))?>
		<hr />

		<?php 
		$controller = $this->getId();
		$action = $this->getAction()->getId();
		$isNode = $controller=="node";
		$isPageAdd = $action == 'add' && !empty($_GET['type']) && $_GET['type'] == Node::TYPE_PAGE && !empty($_GET['id']);
		$isPageView = $action == 'view';
		if($isNode && $isPageView){
			$node = Node::model()->findByPk($_GET['id']);
			if($node->type == Node::TYPE_NEWS){
				$isPageView = false;
			}
		}

		if($isNode && ($isPageAdd || $isPageView)){
			if(empty($node)){
				$node = Node::model()->find(empty($_GET['id'])?$_GET['parent_id']:$_GET['id']);
			}
			if($node->type == Node::TYPE_PAGE){
				if($node->parent_id !=0){
					$root_page = Node::model()->findByPk($node->parent_id);
				}else{
					$root_page = $node;
				}
				$sub_pages =  Node::model()->findAll("parent_id = $root_page->id");
				$navs = array(array('label'=>$root_page->title,'itemOptions'=>array("class"=>'nav-header')));
				foreach ($sub_pages as $sub_page){
					array_push($navs,array('label'=>"<i class='icon-bookmark'></i> $sub_page->title",'url'=>array("node/view","username"=>$user->username,"id"=>$sub_page->id)));
				}


				$this->widget('zii.widgets.CMenu', array(
						'items'=>$navs,
						'encodeLabel'=>false,
						'htmlOptions'=>array("class"=>'nav nav-list'),
				));
				Utils::displayBtn(CHtml::link('<i class="icon-plus icon-black"></i> 创建子页面 ',array("node/add","username"=>$user->username,'parent_id'=>$root_page->id,'type'=>Node::TYPE_PAGE),array("class"=>'btn')));
				echo "<hr/>";
			}
}?>

		<?php 
		if(Utils::displayBtn("")){
			$navs = array(
					array('label'=>'活动', 'url'=>'#',"linkOptions"=>array("class"=>"nav-header")),
					array('label'=>'<i class="icon-plus"></i> 创建一个活动', 'url'=>array('event/add','username'=>$user->username)),
					array('label'=>'<i class="icon-user"></i> 组织的活动', 'url'=>array('event/own','username'=>$user->username)),
					array('label'=>'博客', 'url'=>'#',"linkOptions"=>array("class"=>"nav-header")),
					array('label'=>'<i class="icon-plus"></i> 发布一个博客', 'url'=>array('node/add',"type"=>Node::TYPE_NEWS,'username'=>$user->username)),
					array('label'=>'<i class="icon-user"></i> 博客列表', 'url'=>array('node/list','username'=>$user->username)),
					array('label'=>'管理', 'url'=>'#',"linkOptions"=>array("class"=>"nav-header")),
					array('label'=>'<i class="icon-user"></i> 更新信息', 'url'=>array('member/update','username'=>$user->username)),
					array('label'=>'<i class="icon-asterisk"></i> 修改密码', 'url'=>array('member/password','username'=>$user->username)),
			);

			$this->widget('zii.widgets.CMenu', array(
					'items'=>$navs,
					'encodeLabel'=>false,
					'htmlOptions'=>array("class"=>'nav nav-list'),
			));
		}
		?>
	</div>

	<!--/.well -->
</div>

<div class="span9 div-plain" style='border-radius: 9px'>
	<?php
	foreach(Yii::app()->user->getFlashes() as $key => $message) {
		echo "<div class='alert alert-$key'>$message</div>\n";
	}
	?>
	<?php echo $content?>
</div>
<!--/span-->


<!--/span-->
<?php $this->endContent(); ?>
